package com.tmz.cloudmall.cloudmallmember.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;


import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tmz.cloudmall.cloudmallmember.domain.GrowthChangeHistory;
import com.tmz.cloudmall.cloudmallmember.service.IGrowthChangeHistoryService;
import com.tmz.cloudmall.cloudmallcommon.common.annotation.Log;
import com.tmz.cloudmall.cloudmallcommon.common.core.controller.BaseController;
import com.tmz.cloudmall.cloudmallcommon.common.core.domain.AjaxResult;
import com.tmz.cloudmall.cloudmallcommon.common.core.page.TableDataInfo;
import com.tmz.cloudmall.cloudmallcommon.common.enums.BusinessType;
import com.tmz.cloudmall.cloudmallcommon.common.utils.poi.ExcelUtil;


/**
 * 成长值变化历史记录Controller
 * 
 * @author tmz
 * @date 2025-08-16
 */
@RestController
@RequestMapping("/cloudmallmember/growthChangeHistory")
public class GrowthChangeHistoryController extends BaseController
{
    @Autowired
    private IGrowthChangeHistoryService growthChangeHistoryService;

    /**
     * 查询成长值变化历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('cloudmallmember:growthChangeHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(GrowthChangeHistory growthChangeHistory)
    {
        startPage();
        List<GrowthChangeHistory> list = growthChangeHistoryService.selectGrowthChangeHistoryList(growthChangeHistory);
        return getDataTable(list);
    }

    /**
     * 导出成长值变化历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('cloudmallmember:growthChangeHistory:export')")
    @Log(title = "成长值变化历史记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GrowthChangeHistory growthChangeHistory)
    {
        List<GrowthChangeHistory> list = growthChangeHistoryService.selectGrowthChangeHistoryList(growthChangeHistory);
        ExcelUtil<GrowthChangeHistory> util = new ExcelUtil<GrowthChangeHistory>(GrowthChangeHistory.class);
        util.exportExcel(response, list, "成长值变化历史记录数据");
    }

    /**
     * 获取成长值变化历史记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('cloudmallmember:growthChangeHistory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(growthChangeHistoryService.selectGrowthChangeHistoryById(id));
    }

    /**
     * 新增成长值变化历史记录
     */
    @PreAuthorize("@ss.hasPermi('cloudmallmember:growthChangeHistory:add')")
    @Log(title = "成长值变化历史记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GrowthChangeHistory growthChangeHistory)
    {
        return toAjax(growthChangeHistoryService.insertGrowthChangeHistory(growthChangeHistory));
    }

    /**
     * 修改成长值变化历史记录
     */
    @PreAuthorize("@ss.hasPermi('cloudmallmember:growthChangeHistory:edit')")
    @Log(title = "成长值变化历史记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GrowthChangeHistory growthChangeHistory)
    {
        return toAjax(growthChangeHistoryService.updateGrowthChangeHistory(growthChangeHistory));
    }

    /**
     * 删除成长值变化历史记录
     */
    @PreAuthorize("@ss.hasPermi('cloudmallmember:growthChangeHistory:remove')")
    @Log(title = "成长值变化历史记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(growthChangeHistoryService.deleteGrowthChangeHistoryByIds(ids));
    }
}
